package cn.wolfcode.p2p.business.service.impl;

import cn.wolfcode.p2p.business.domain.BidRequest;
import cn.wolfcode.p2p.business.domain.BidRequestAuditHistory;
import cn.wolfcode.p2p.business.mapper.BidRequestAuditHistoryMapper;
import cn.wolfcode.p2p.business.service.IBidRequestAuditHistoryService;
import cn.wolfcode.p2p.util.UserContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class BidRequestAuditHistoryServiceImpl implements IBidRequestAuditHistoryService {

    @Autowired
    private BidRequestAuditHistoryMapper bidRequestAuditHistoryMapper;

    @Override
    public void save(BidRequest bidRequest,Integer state,String remark,Integer auditType) {
        //保存审核记录
        BidRequestAuditHistory bidRequestAuditHistory = new BidRequestAuditHistory();
        bidRequestAuditHistory.setBidRequestId(bidRequest.getId());
        bidRequestAuditHistory.setAuditType(auditType);
        bidRequestAuditHistory.setState(state);
        bidRequestAuditHistory.setRemark(remark);
        bidRequestAuditHistory.setAuditTime(new Date());
        bidRequestAuditHistory.setApplyTime(bidRequest.getApplyTime());
        bidRequestAuditHistory.setAuditor(UserContext.getLoginInfo());
        bidRequestAuditHistory.setApplier(bidRequest.getCreateUser());
        bidRequestAuditHistoryMapper.insert(bidRequestAuditHistory);
    }

    @Override
    public List<BidRequestAuditHistory> listByBidRequestId(Long id) {

        return bidRequestAuditHistoryMapper.listByBidRequestId(id);
    }
}
